<?php
use Base\AdminController;
use Illuminate\Support\Str;
use JetBrains\PhpStorm\NoReturn;

/**
 * 职位表
 */
class PositionController extends AdminController
{
	protected string $table = "positions";

    protected string $model = "position";

	#[NoReturn] public function init(): void
    {
        if (Request::input("title")) {
            $this->where[] = ['title','like', '%'.Request::input("title").'%'];
        }
        if (Request::input("id")) {
            $this->where[] = ['org_id','=',Request::input("id")];
        }
        if (Request::input("category_id")) {
            $this->where[] = ['category_id','=',Request::input("category_id")];
        }
        $this->routeWhiteLst = ['position@all'];
        parent::init();
    }

    #[NoReturn] public function allAction(): void
    {
        $data = PositionModel::query()->selectRaw("id as value,title as label")->get()->toArray();
        $this->apiSuccess($data,"success",20000);
    }
}
